{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_edu_cloud_search' %}
{% set script_controller = 'setting/search' %}

{% block main %}

{{ web_macro.flash_messages() }}

<div class="page-header clearfix">
  <h1 class="pull-left">云搜索</h1>
</div>
<form class="form-horizontal" id="cloud-setting-form" method="post" novalidate>

    {{ render(controller('TopxiaAdminBundle:Default:inspect')) }}
    {% if data.status == 'unlink' %}
      <div class="text-center">
        <h1 class="text-muted">网络问题，无法连接{{ 'EduSoho'|copyright_less }}开放云平台</h1>
      </div>
    {% else %}
      <div class="row form-group search-button">
        {% if data.status == 'unconnect' %}
          <div class="col-md-2">
            <button type="submit" class="btn btn-default" name="upload_mode" value="cloud" disabled="disabled">启用云搜索</button>
          </div>
          <div class="col-md-10">
            <span class="text-danger text-sm" >抱歉，您尚未接入教育云，不能使用云搜索服务！</span>
            <p><a href="http://open.edusoho.com/educloud" target="_blank">立即接入</a></p>
          </div>
        {% elseif data.status == 'unbinded' %}
          <div class="col-md-2">
            <button type="submit" class="btn btn-default" name="upload_mode" value="cloud" disabled="disabled">启用云搜索</button>
          </div>
          <div class="col-md-10">
            <span class="text-danger text-sm" >未绑定授权域名不能开通云搜索！</span>
            <p><a href="{{path('admin_setting_cloud')}}">立即设置</a></p>
          </div>
        {% elseif data.status == 'binded_error' %}
          <div class="col-md-2">
            <button type="submit" class="btn btn-default" name="upload_mode" value="cloud" disabled="disabled">启用云搜索</button>
          </div>
          <div class="col-md-10">
            <span class="text-danger text-sm" >当前域名与授权域名不符，不能开通云搜索！</span>
            <p><a href="{{path('admin_setting_cloud')}}" target="_blank">立即设置</a></p>
          </div>
        {% elseif data.status == 'closed' %}
            <div class="col-md-2">
              <a class="btn btn-primary mhs" data-toggle="modal" data-target="#modal" data-url="{{ path('admin_edu_cloud_search_clause') }}">启用云搜索</a>
          </div>

        {% else %}
          {% if not setting('cloud_search.search_enabled') %}
            <div class="col-md-2 control-cloud">
               <a class="btn btn-primary mhs" href="{{ path('admin_edu_cloud_search_open') }}">启用云搜索</a>
            </div>
          {% elseif setting('cloud_search.search_enabled') and setting('cloud_search.status') == 'waiting' %}
            <div class="col-md-10 form-group control-cloud">
              <span class="text-warning">正在索引数据，预计1～3天完成</span>
            </div>
          {% elseif setting('cloud_search.search_enabled') and setting('cloud_search.status') == 'ok' %}
            <div class="col-md-2 control-cloud success">
              <span class="text-success">已启用</span>
            </div>
            <div class="controls col-md-8 cloud-warning">
              <a class="btn btn-default btn-sm mhs" href="{{ path('admin_edu_cloud_search_close') }}">关闭</a>
            </div>
          {% endif %}

          {% if setting('developer.debug')%}
            <div class="col-md-2">
              <a class="btn btn-primary mhs" data-toggle="modal" data-target="#modal" data-url="{{ path('admin_edu_cloud_search_reapply') }}">重建索引</a>
            </div>
          {% endif %}
        {% endif %}
      </div>

      <div class="help-block">云搜索提供强大的全文搜索引擎，帮助学员轻松、精确的搜索课程、老师、小组话题、资讯。</div>

      <h4>搜索范围说明</h4>

      －课程：包括课程标题、课程简介、课时标题等内容关键词全文搜索。<br>
      －教师：教师姓名、教师头衔。<br>
      －小组话题：包括话题标题、正文等关键词全文搜索。<br>
      －资讯：包括资讯标题、正文等关键词全文搜索。<br>
    {% endif %}


</form>

{% endblock %}